From 2fc12bf563c56955ab6bedfb0b81884513780cd7 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Mon, 11 Jul 2022 12:01:00 -0600 Subject: [PATCH] use utf-16 string literals with [QDateTime,QDate,QTime]::toString format parameters. --- dg-100.cc | 2 +- exif.cc | 6 +++--- gpssim.cc | 4 ++-- kml.cc | 2 +- lowranceusr.cc | 16 ++++++++-------- magproto.cc | 4 ++-- nmea.cc | 4 ++-- subrip.cc | 2 +- trackfilter.cc | 4 ++-- unicsv.cc | 8 ++++---- xcsv.cc | 6 +++--- 11 files changed, 29 insertions(+), 29 deletions(-) diff --git a/dg-100.cc b/dg-100.cc index a1f31045f..924fdc0fb 100644 --- a/dg-100.cc +++ b/dg-100.cc @@ -201,7 +201,7 @@ Dg100Format::process_gpsfile(uint8_t data[], route_head** track) const int bintime = be_read32(data + i + 8) & 0x7FFFFFFF; int bindate = be_read32(data + i + 12); QDateTime creation_time = bintime2utc(bindate, bintime); - QString datetime = creation_time.toString("yyyy/MM/dd hh:mm:ss"); + QString datetime = creation_time.toString(u"yyyy/MM/dd hh:mm:ss"); *track = new route_head; (*track)->rte_name = QStringLiteral("%1 tracklog (%2)").arg(model->name, datetime); (*track)->rte_desc = "GPS tracklog data"; diff --git a/exif.cc b/exif.cc index b6679aab7..78c605f0a 100644 --- a/exif.cc +++ b/exif.cc @@ -194,10 +194,10 @@ ExifFormat::exif_type_size(const uint16_t type) QString ExifFormat::exif_time_str(const QDateTime& time) { - QString str = time.toString("yyyy/MM/dd hh:mm:ss t"); + QString str = time.toString(u"yyyy/MM/dd hh:mm:ss t"); if (time.timeSpec() != Qt::UTC) { str.append(" ("); - str.append(time.toUTC().toString("yyyy/MM/dd hh:mm:ss t")); + str.append(time.toUTC().toString(u"yyyy/MM/dd hh:mm:ss t")); str.append(")"); } return str; @@ -1554,7 +1554,7 @@ ExifFormat::write() exif_put_double(GPS_IFD, GPS_IFD_TAG_TIMESTAMP, 1, dt.time().minute()); exif_put_double(GPS_IFD, GPS_IFD_TAG_TIMESTAMP, 2, dt.time().second()); - exif_put_str(GPS_IFD, GPS_IFD_TAG_DATESTAMP, CSTR(dt.toString("yyyy:MM:dd"))); + exif_put_str(GPS_IFD, GPS_IFD_TAG_DATESTAMP, CSTR(dt.toString(u"yyyy:MM:dd"))); } else { exif_remove_tag(GPS_IFD, GPS_IFD_TAG_TIMESTAMP); exif_remove_tag(GPS_IFD, GPS_IFD_TAG_DATESTAMP); diff --git a/gpssim.cc b/gpssim.cc index c71f4158a..138dc139b 100644 --- a/gpssim.cc +++ b/gpssim.cc @@ -125,8 +125,8 @@ gpssim_write_pt(const Waypoint* wpt) if (wpt->creation_time.isValid()) { char tbuf[20]; - QByteArray dmy = wpt->GetCreationTime().toUTC().toString("ddMMyy").toUtf8(); - QByteArray hms = wpt->GetCreationTime().toUTC().toString("hhmmss").toUtf8(); + QByteArray dmy = wpt->GetCreationTime().toUTC().toString(u"ddMMyy").toUtf8(); + QByteArray hms = wpt->GetCreationTime().toUTC().toString(u"hhmmss").toUtf8(); snprintf(tbuf, sizeof(tbuf), ",%s,%s",dmy.constData(), hms.constData()); strcat(obuf, tbuf); diff --git a/kml.cc b/kml.cc index 3abbbd4b6..fbb5b04ca 100644 --- a/kml.cc +++ b/kml.cc @@ -1301,7 +1301,7 @@ void KmlFormat::kml_geocache_pr(const Waypoint* waypointp) const kml_output_timestamp(waypointp); QString date_placed; if (waypointp->GetCreationTime().isValid()) { - date_placed = waypointp->GetCreationTime().toString("dd-MMM-yyyy"); + date_placed = waypointp->GetCreationTime().toString(u"dd-MMM-yyyy"); } writer->writeTextElement(QStringLiteral("styleUrl"), QStringLiteral("#geocache")); diff --git a/lowranceusr.cc b/lowranceusr.cc index 85b6f4c78..03cb38442 100644 --- a/lowranceusr.cc +++ b/lowranceusr.cc @@ -468,10 +468,10 @@ LowranceusrFormat::lowranceusr_parse_waypt(Waypoint* wpt_tmp, int object_num_pre if (global_opts.debug_level > 2) { if (global_opts.debug_level == 99) { - printf(" '%s'", qPrintable(wpt_tmp->GetCreationTime().toString("yyyy/MM/dd hh:mm:ss"))); + printf(" '%s'", qPrintable(wpt_tmp->GetCreationTime().toString(u"yyyy/MM/dd hh:mm:ss"))); } else { printf(MYNAME " parse_waypt: creation time '%s', waypt_time %" PRId64 "\n", - qPrintable(wpt_tmp->GetCreationTime().toString("yyyy/MM/dd hh:mm:ss")), waypt_time); + qPrintable(wpt_tmp->GetCreationTime().toString(u"yyyy/MM/dd hh:mm:ss")), waypt_time); } } @@ -626,7 +626,7 @@ LowranceusrFormat::lowranceusr4_parse_waypt(Waypoint* wpt_tmp) const } else { printf(" %6s %16s", QByteArray::number(desc.length()).constData(), qPrintable(desc)); } - printf(" '%s'", qPrintable(wpt_tmp->GetCreationTime().toString("yyyy/MM/dd hh:mm:ss"))); + printf(" '%s'", qPrintable(wpt_tmp->GetCreationTime().toString(u"yyyy/MM/dd hh:mm:ss"))); printf(" %08x %8.3f %08x %08x %08x\n", unused_byte, fsdata->depth, loran_GRI, loran_Tda, loran_Tdb); } else { @@ -1064,7 +1064,7 @@ LowranceusrFormat::lowranceusr4_parse_trail(int* trail_num) const int create_time = gbfgetint32(file_in); if (global_opts.debug_level == 99) { QDateTime qdt = lowranceusr4_get_timestamp(create_date, create_time); - printf(MYNAME " parse_trails: creation date/time = %s\n", qPrintable(qdt.toString("yyyy-MM-dd hh:mm:ss AP"))); + printf(MYNAME " parse_trails: creation date/time = %s\n", qPrintable(qdt.toString(u"yyyy-MM-dd hh:mm:ss AP"))); } /* Some flag bytes */ @@ -1129,7 +1129,7 @@ LowranceusrFormat::lowranceusr4_parse_trail(int* trail_num) const if (global_opts.debug_level >= 2) { if (global_opts.debug_level == 99) { printf(MYNAME " parse_trails: %+14.9f %+14.9f", wpt_tmp->longitude, wpt_tmp->latitude); - printf(" '%s'", qPrintable(wpt_tmp->GetCreationTime().toString("yyyy/MM/dd hh:mm:ss"))); + printf(" '%s'", qPrintable(wpt_tmp->GetCreationTime().toString(u"yyyy/MM/dd hh:mm:ss"))); } else { printf(MYNAME " parse_trails: added trailpoint %+.9f,%+.9f to trail %s\n", wpt_tmp->longitude, wpt_tmp->latitude, qPrintable(trk_head->rte_name)); @@ -1224,7 +1224,7 @@ LowranceusrFormat::read() int create_time = gbfgetint32(file_in); if (global_opts.debug_level >= 1) { QDateTime qdt = lowranceusr4_get_timestamp(create_date, create_time); - printf(MYNAME " creation date/time : '%s'\n", qPrintable(qdt.toString("yyyy-MM-dd hh:mm:ss AP"))); + printf(MYNAME " creation date/time : '%s'\n", qPrintable(qdt.toString(u"yyyy-MM-dd hh:mm:ss AP"))); } unsigned char byte = gbfgetc(file_in); /* unused, apparently */ @@ -1334,7 +1334,7 @@ LowranceusrFormat::lowranceusr_waypt_disp(const Waypoint* wpt) const /* Lowrance needs it as seconds since Jan 1, 2000 */ waypt_time -= base_time_secs; if (global_opts.debug_level >= 2) { - printf("creation_time %" PRId64 ", '%s'", waypt_time, qPrintable(wpt->GetCreationTime().toString("yyyy-MM-dd hh:mm:ss"))); + printf("creation_time %" PRId64 ", '%s'", waypt_time, qPrintable(wpt->GetCreationTime().toString(u"yyyy-MM-dd hh:mm:ss"))); } } else { /* If false, make sure it is an unknown time value */ @@ -1880,7 +1880,7 @@ LowranceusrFormat::write() /* date string */ gpsbabel::DateTime now = current_time().toUTC(); - lowranceusr4_writestr(now.toString("MM/dd/yyyy"), file_out, 1); + lowranceusr4_writestr(now.toString(u"MM/dd/yyyy"), file_out, 1); /* creation date/time */ auto ts = lowranceusr4_jd_from_timestamp(now); diff --git a/magproto.cc b/magproto.cc index 521ab9339..e5a278f29 100644 --- a/magproto.cc +++ b/magproto.cc @@ -1422,8 +1422,8 @@ void mag_track_disp(const Waypoint* waypointp) QDateTime dt = waypointp->GetCreationTime().toUTC(); dt = dt.addMSecs(10 * lround(dt.time().msec()/10.0) - dt.time().msec()); assert((dt.time().msec() % 10) == 0); - dmy = dt.toString("ddMMyy").toUtf8(); - hms = dt.toString("hhmmss.zzz").left(9).toUtf8(); + dmy = dt.toString(u"ddMMyy").toUtf8(); + hms = dt.toString(u"hhmmss.zzz").left(9).toUtf8(); } double lon = fabs(ilon); diff --git a/nmea.cc b/nmea.cc index 8a3c92795..566c5ecfe 100644 --- a/nmea.cc +++ b/nmea.cc @@ -1222,8 +1222,8 @@ NmeaFormat::nmea_trackpt_pr(const Waypoint* wpt) QByteArray dmy(""); QByteArray hms(""); if (wpt->GetCreationTime().isValid()) { - dmy = wpt->GetCreationTime().toUTC().toString("ddMMyy").toUtf8(); - hms = wpt->GetCreationTime().toUTC().toString("hhmmss.zzz").toUtf8(); + dmy = wpt->GetCreationTime().toUTC().toString(u"ddMMyy").toUtf8(); + hms = wpt->GetCreationTime().toUTC().toString(u"hhmmss.zzz").toUtf8(); } switch (wpt->fix) { diff --git a/subrip.cc b/subrip.cc index 6bcb1c7d0..6b5757d81 100644 --- a/subrip.cc +++ b/subrip.cc @@ -180,7 +180,7 @@ SubripFormat::subrip_trkpt_pr(const Waypoint* waypointp) qDebug().noquote() << "GPS track start is " << waypointp->GetCreationTime().toUTC().toString(Qt::ISODateWithMs); qDebug().noquote() << "Synchronizing" - << video_time(gps_datetime).toString("HH:mm:ss,zzz") + << video_time(gps_datetime).toString(u"HH:mm:ss,zzz") << "to" << gps_datetime.toString(Qt::ISODateWithMs); qDebug().noquote() << "Video start 00:00:00,000 is" << video_datetime.toString(Qt::ISODateWithMs); diff --git a/trackfilter.cc b/trackfilter.cc index a1a435f24..0163ca5b2 100644 --- a/trackfilter.cc +++ b/trackfilter.cc @@ -238,9 +238,9 @@ void TrackFilter::trackfilter_split_init_rte_name(route_head* track, const gpsba QString datetimestring; if (opt_interval != 0) { - datetimestring = dt.toUTC().toString("yyyyMMddhhmmss"); + datetimestring = dt.toUTC().toString(u"yyyyMMddhhmmss"); } else { - datetimestring = dt.toUTC().toString("yyyyMMdd"); + datetimestring = dt.toUTC().toString(u"yyyyMMdd"); } if ((opt_title != nullptr) && (strlen(opt_title) > 0)) { diff --git a/unicsv.cc b/unicsv.cc index acfd05001..6788f6dac 100644 --- a/unicsv.cc +++ b/unicsv.cc @@ -1147,7 +1147,7 @@ UnicsvFormat::unicsv_print_data_time(const QDateTime& idt) const dt = dt.toUTC(); } - unicsv_print_str(dt.toString("yyyy/MM/dd hh:mm:ss")); + unicsv_print_str(dt.toString(u"yyyy/MM/dd hh:mm:ss")); } #define FIELD_USED(a) (gb_getbit(&unicsv_outp_flags, a)) @@ -1547,7 +1547,7 @@ UnicsvFormat::unicsv_waypt_disp_cb(const Waypoint* wpt) } else { dt = wpt->GetCreationTime().toLocalTime(); } - QString date = dt.toString("yyyy/MM/dd"); + QString date = dt.toString(u"yyyy/MM/dd"); *fout << unicsv_fieldsep << date; } else { *fout << unicsv_fieldsep; @@ -1564,9 +1564,9 @@ UnicsvFormat::unicsv_waypt_disp_cb(const Waypoint* wpt) } QString out; if (t.msec() > 0) { - out = t.toString("hh:mm:ss.zzz"); + out = t.toString(u"hh:mm:ss.zzz"); } else { - out = t.toString("hh:mm:ss"); + out = t.toString(u"hh:mm:ss"); } *fout << unicsv_fieldsep << out; } else { diff --git a/xcsv.cc b/xcsv.cc index 9d9af116b..8adc85cb9 100644 --- a/xcsv.cc +++ b/xcsv.cc @@ -1590,13 +1590,13 @@ XcsvFormat::xcsv_replace_tokens(const QString& original) const QDateTime dt = current_time().toUTC(); - QString dts = dt.toString("ddd MMM dd hh:mm:ss yyyy"); + QString dts = dt.toString(u"ddd MMM dd hh:mm:ss yyyy"); replacement.replace("__DATE_AND_TIME__", dts); - QString d = dt.toString("MM/dd/yyyy"); + QString d = dt.toString(u"MM/dd/yyyy"); replacement.replace("__DATE__", d); - QString t = dt.toString("hh:mm:ss"); + QString t = dt.toString(u"hh:mm:ss"); replacement.replace("__TIME__", t); } return replacement; -- 2.30.2